/*
ID: quxiao82
LANG: C++
PROG: ratios
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>

const int NUM = 3;
const int MAX = 100;
const int INF = 1000;

int goalRatio[NUM];
int ratios[NUM][NUM];
int goalMulti, minMulti[NUM];

void Input ()
{
     int i, j;
     for (i = 0; i < NUM; i ++)
          scanf("%d", &goalRatio[i]);
     for (i = 0; i < NUM; i ++)
          for (j = 0; j < NUM; j ++)
               scanf("%d", &ratios[i][j]);
}

int getMulti(int multis[NUM])
{
     int feeds[NUM], i, j;
     int tmp[NUM];
     for (i = 0; i < NUM; i ++)
     {
          feeds[i] = 0;
          for (j = 0; j < NUM; j ++)
               feeds[i] += ratios[j][i] * multis[j];
     }
     int tmpMulti = -1;
     for (i = 0; i < NUM; i ++)
     {
          if ( goalRatio[i] )
          {
               if ( feeds[i] % goalRatio[i] )
                    return -1;
               if ( tmpMulti == -1 )
                    tmpMulti = feeds[i] / goalRatio[i];
               else if ( tmpMulti != feeds[i] / goalRatio[i] )
                    return -1;
          }
          else if ( feeds[i] )
          {
               return -1;
          }
     }
     if ( tmpMulti > 0 )
          return tmpMulti;
     return -1;
}

void Search (int depth, int multis[NUM])
{
     if ( depth == NUM )    
     {
          int tmp, sum;
          if ( (tmp=getMulti(multis)) >= 0 )
          {
               if ( multis[0] + multis[1] + multis[2] < minMulti[0] + minMulti[1] + minMulti[2] )
               {
                    minMulti[0] = multis[0];
                    minMulti[1] = multis[1];
                    minMulti[2] = multis[2];
                    goalMulti = tmp;
               }
          }
     }
     else
     {
          int i;
          for (i = 0; i < MAX; i ++)
          {
               multis[depth] = i;
               Search(depth+1, multis);
          }
     }
}

void Solve ()
{
     int multis[NUM];
     minMulti[0] = minMulti[1] = minMulti[2] = INF;
     goalMulti = -1;
     Search(0, multis);
     if ( goalMulti == -1 )
          printf("NONE\n");
     else
          printf("%d %d %d %d\n", minMulti[0], minMulti[1], minMulti[2], goalMulti);
}

int main ()
{
     freopen("ratios.in", "r", stdin);
     freopen("ratios.out", "w", stdout);

     Input ();
     Solve ();

     return 0;
}